import {wxRequest} from '../../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()

Page({
  data: {
    datalist: []
  },

  onLoad: function(options) { 
    this.getlist();
  },

  // 获取产地列表
  getlist: function() {
    var that = this
    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + "/org/protected/comm/beanCrud/org.SupplierVO/find",
      method: "post",
      data: {
        keyword: that.data.keywords,
        pageSize: 10000
      }
    }, function(res) {
      console.log(res)
      that.setData({
        datalist: res.list
      })
    })
  },

 
//监听搜索
  seacherOn: function(e) {
    var keywords = e.detail
    this.setData({
      keywords
    })
    this.getlist()
  },


  //选择供应商
  choose: function(e) {
    console.log('choose', e)
    var item = e.currentTarget.dataset.item

    //直接调用上一个页面的setData()方法，把数据存到上一个页面中去
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2]; //上一个页面    
    prevPage.setData({
      supplyItem: item,
    })
    wx.navigateBack();
  },
 

})